package farmaciaweb.com.br.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import farmaciaweb.com.br.dao.EstadoDAO;
import farmaciaweb.com.br.entity.Estado;
import farmaciaweb.com.br.util.JPAUtil;

@PersistenceContext(unitName = "FarmaciaWebJPA")
public class EstadoDAOImpl implements EstadoDAO{
	private static final long serialVersionUID = -2648232287436479506L;
	private EntityManager em;
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Estado> findAll() {
		this.em = JPAUtil.getEntityManger();
		Query query = this.em.createQuery("SELECT e FROM Estado e ORDER BY e.nmEstado");
		return query.getResultList();
	}

	public EntityManager getEm() {
		return em;
	}

	public void setEm(EntityManager em) {
		this.em = em;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}
